import re

import requests
from bs4 import BeautifulSoup

url = 'http://www.fontawesome.com.cn/faicons/'
res = requests.get(url)
res.encoding = 'utf-8'
soup = BeautifulSoup(res.text, 'lxml')
icon_list = []
def get_icon(args):
    for item in args:
        return item.split(' ')[-1]
with open('d:\icon.txt', mode='w+', encoding='utf-8') as file1:
    for item in soup.select('.fa'):
        regx = r'"(.*)"'
        value_list = re.findall(regx, str(item))
        icon = get_icon(value_list)
        value = "['%s','%s']," % (icon, str(item))
        file1.write(value)
        file1.write('\n')



